package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.dto.TransshipmentDTO;
import net.wanho.po.Transshipment;
import net.wanho.service.TransshipmentService;
import net.wanho.vo.PageInfo;
import net.wanho.vo.R;
import net.wanho.vo.TransshipmentVo;
import org.springframework.web.bind.annotation.*;

/**
 * Author：汤小洋
 * Date：2024-10-24 13:37
 * Description：<描述>
 */
@RestController
@RequestMapping("/transshipment")
@RequiredArgsConstructor
public class TransshipmentController {

    private final TransshipmentService transshipmentService;

    @GetMapping("/transshipment-page-list")
    public R pageList(@RequestParam(defaultValue = "1") int pageNum,
                      @RequestParam(defaultValue = "5") int pageSize,
                      TransshipmentDTO transshipmentDTO){
        PageInfo<TransshipmentVo> pageInfo = transshipmentService.pageList(pageNum, pageSize, transshipmentDTO);
        return R.success(pageInfo);
    }

    @PostMapping("/transshipment-add")
    public R addTransshipment(@RequestBody Transshipment transshipment){
        transshipmentService.addTransshipment(transshipment);
        return R.success("添加调货单成功！");
    }

    @PutMapping("/transshipment-confirm")
    public R confirmTransshipment(@RequestBody Transshipment transshipment){
        transshipmentService.confirmTransshipment(transshipment);
        return R.success("确认调货单成功！");
    }

}
